package cn.zc.student.service.service.impl;


import cn.tools.dozer.config.DozerUtils;
import cn.zc.student.entity.Role;
import cn.zc.student.entity.VO.RoleVO;
import cn.zc.student.service.mapper.RoleMapper;
import cn.zc.student.service.service.RoleService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
    @Resource
    private DozerUtils dozerUtils;

    @Resource
    private RoleMapper roleMapper;

    /**
     * 查询权限
     * @param userId
     * @return
     */
    @Override
    public List<RoleVO> getRole(String userId) {
        List<Role> roles = roleMapper.selectList(new QueryWrapper<Role>().lambda().eq(Role::getUserId, userId));
        return dozerUtils.mapList(roles, RoleVO.class);
    }
}
